package see.battle.gui;

import see.battle.Const;
import see.battle.Utils;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.MotionEvent;
import android.view.Window;
import android.view.WindowManager;

public class GameSelection extends Activity {
  
  private GameSelectionView _gameSelectionView;
  
  public boolean onTouchEvent(MotionEvent e) {
    if (e.getActionMasked() == MotionEvent.ACTION_DOWN) {
      int w = _gameSelectionView.get_widthInPx();
      int h = _gameSelectionView.get_heightInPx();
      float x = e.getX();
      float y = e.getY();
      if (Utils.isInsideRect(x, y, w, h, 1)) {
        Intent intent = new Intent(this, Game.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
        intent.putExtra("GAME_MODE", Const.noServer);
        startActivity(intent);
      } else if (Utils.isInsideRect(x, y, w, h, 2)) { 
        Intent intent = new Intent(this, ActionSelection.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
        startActivity(intent);
      }
    }
    return true;
  }
  
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
        WindowManager.LayoutParams.FLAG_FULLSCREEN);
  }
  
  @Override
  public void onStart() {
    super.onStart();
    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    _gameSelectionView = new GameSelectionView(this, metrics);
    setContentView(_gameSelectionView);
  }

}
